Part01-01: Listing 38 with multiple mov instructions now working
				
					
				
			This commit is contained in:
		
							parent
							
								
									6ad9f66bc7
								
							
						
					
					
						commit
						6066e930db
					
				
							
								
								
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							| @ -1,2 +1,3 @@ | ||||
| /decode | ||||
| /.idea/ | ||||
| /asm_files/*.bin | ||||
|  | ||||
							
								
								
									
										17
									
								
								asm_files/01-01-38.asm
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								asm_files/01-01-38.asm
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,17 @@ | ||||
| ; ======================================================================== | ||||
| ; LISTING 38 | ||||
| ; ======================================================================== | ||||
| 
 | ||||
| bits 16 | ||||
| 
 | ||||
| mov cx, bx | ||||
| mov ch, ah | ||||
| mov dx, bx | ||||
| mov si, bx | ||||
| mov bx, di | ||||
| mov al, cl | ||||
| mov ch, ch | ||||
| mov bx, ax | ||||
| mov bx, si | ||||
| mov sp, di | ||||
| mov bp, ax | ||||
							
								
								
									
										15
									
								
								decode.c
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								decode.c
									
									
									
									
									
								
							| @ -60,11 +60,11 @@ int main(int argc, char **argv) | ||||
| 
 | ||||
|     printf("; Decoded 8086 Assembly Instructions\n\n"); | ||||
|     printf("bits 16\n\n"); | ||||
|     for (int i = 0; i < (int)bytes_read / 2; i += 2) | ||||
|     for (int i = 0; i < (int)bytes_read; i += 2) | ||||
|     { | ||||
|         char low_byte = buf[i]; | ||||
|         char high_byte = buf[i+1]; | ||||
|         // char w = byte & 0b00000001;
 | ||||
|         char w = low_byte & 0b00000001; | ||||
|         char d = low_byte & 0b00000010; | ||||
|         char mod = (high_byte & 0b11000000) >> 6; | ||||
|         char reg = (high_byte & 0b00111000) >> 3; | ||||
| @ -78,12 +78,19 @@ int main(int argc, char **argv) | ||||
|         case INST_MOV: | ||||
|             if (mod == MODE_REGMODE) | ||||
|             { | ||||
|                 printf("mov %s, %s", dst_reg.fullname, src_reg.fullname); | ||||
|                 if (w == 1) | ||||
|                 { | ||||
|                     printf("mov %s, %s", dst_reg.fullname, src_reg.fullname); | ||||
|                 } | ||||
|                 else | ||||
|                 { | ||||
|                     printf("mov %s, %s", dst_reg.bytename, src_reg.bytename); | ||||
|                 } | ||||
|             } | ||||
|             break; | ||||
|         default: | ||||
|             perror("Unrecognized Instruction\n"); | ||||
|         } | ||||
|         printf("\n"); | ||||
|     } | ||||
|     printf("\n"); | ||||
| } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user