Well, I used to think HTML was bad.. then I started using CSS then C, then C++, then PHP, then this sem I’m having to learn SQL and to REALLY top it off, Assembly Language. I mean, this is the most super super basic language of programming, just short of entering all the 1’s and 0’s into the computer as binary code. Its ridiculous! Check this ’simple’ program out!
; This program reads 5 single-digit numbers from the keyboard and
; then output it to the monitor in ascending order
;
;
stk segment stack
db 1024 DUP(?)
tos label word
stk ends
;
data segment
array db 5 dup (?)
data ends
;
code segment
assume cs:code, ss:stk, ds:data
count equ 5
;
start: mov ax,stk ;initialize stack
mov ss,ax
mov sp,offset tos
mov ax,data ;initialize data segment
mov ds,ax
;
; Read in the 5 single digit number from the keyboard and store at array
xor ch,ch ;initialize counter
mov cl,count
xor bx,bx ;initialize index register
key: mov ah,7 ;read in number
int 21h
cmp al,30h ;check that it is a digit
jl key ;otherwise re-read the keyboard
cmp al,39h
jg key
mov array[bx],al ;store the number at the array
mov ah,2 ;display the number at the screen
mov dl,al
int 21h
inc bl ;increment index register
dec cl ;decrement counter
jnz key ;continue reading
;
; The 5 numbers are rearranged in ascending order
xor ch,ch ;initialize counter
mov cl,count-1
xor bx,bx ;initialize index register
again: mov al,array[bx] ;compare 2 adjacent numbers
cmp al,array[bx+1]
jle next ;process next data if in order
xchg al, array[bx+1] ;exchange the data
xchg al, array[bx]
cmp bx, 0h ;if first piece of data, go on
jz next
dec bx ;otherwise move back the array and check
inc cl
jmp again
next: inc bx ;process next piece
dec cl
jz done
jmp again
;
;display the 5 data at the console
done: xor ch,ch ;initialize counter
mov cl,count
xor bx,bx ;initialize index register
mov ah,2 ;sent space
mov dl,20h
int 21h
next1: mov ah,2
mov dl,array[bx] ;display data on screen
int 21h
inc bx ;next piece
dec cl
jnz next1
;
; call exit function to DOS
exit1: mov ah,4ch
int 21h
code ends
end start
If thats not cryptic enough for you.. You must be some cold unfeeling machine. Imagine it without all the comments. Sigh. SQL is pretty simple though, very intuitive. I guess its just the database logic and efficiency I must learn.
Oh man.. Am I really a computer person? or just a lazy engineer who doesn’t want to work thats why cannot even pass? Pending my decision to switch faculty, I really still have left the “Have I worked hard enough or do I honestly have no aptitude for engineering?” question unanswered.
Finally, I’m feeling extremely disorganized. I feel like there’s a TON of admin info, and maybe another 2 TONS of homework and lecture slides I need to work my way through. I am officially OVERWHELMED, just 2 weeks and 2 hours into the sem. Well done *pats myself on the back*. I need some3 TONS of divine guidance on my organization.